package com.elong.android.specialhouse.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.TextView;

import com.elong.android.specialhouse.AppConstants;
import com.elong.android.specialhouse.R;
import com.elong.android.specialhouse.base.BaseVolleyActivity;
import com.elong.android.specialhouse.utils.EventReportTools;
import com.elong.framework.netmid.response.IResponse;

public class PaySuccessActivity extends BaseVolleyActivity<IResponse<?>> {
	private static final String PAGE_NAME = "youfangPaymentSuccessPage";
	private static final int REQUEST_ACTIVITY_PAYMENT = 0;
	private TextView tvSeeOrder;
	private TextView tvReturnHome;

	private String mGorderId;
	private String mOrderId;
	private String mApartmentName;
	private Intent mIntent;

	@Override
	protected void initContentView() {
		setContentView(R.layout.act_pay_success);
		tvSeeOrder = (TextView) findViewById(R.id.tv_see_order);
		tvReturnHome = (TextView) findViewById(R.id.tv_return_home);
		setListener();
	}

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		EventReportTools.sendPageOpenEvent(PAGE_NAME);
		initData();
	}

	private void setListener() {
		tvSeeOrder.setOnClickListener(this);
		tvReturnHome.setOnClickListener(this);
	}

	private void initData() {
		mIntent = getIntent();
		mGorderId = mIntent.getStringExtra(AppConstants.GORDER_ID);
		mOrderId = mIntent.getStringExtra(AppConstants.ORDER_ID);
	}

	@Override
	public void onClick(View v) {
		super.onClick(v);
		switch (v.getId()) {
		case R.id.tv_see_order:
			// 查看订单详情
			EventReportTools.sendPageSpotEvent(PAGE_NAME, "seeOrder");//查看订单seeOrder
			goToOrderDetailPage();
			break;
		case R.id.tv_return_home:
			// 返回首页
			EventReportTools.sendPageSpotEvent(PAGE_NAME, "home");//返回首页home
			goToHomePage();
			break;
		default:
			break;
		}
	}

	private void goToOrderDetailPage() {
		Intent intent = new Intent(this, MyOrderDetailActivity.class);
		intent.putExtra("mGorderId", mGorderId);
		intent.putExtra(AppConstants.KEY_IS_FROM_ORDER_LIST_PAGE, false);
		startActivity(intent);
		finish();
	}

	private void goToHomePage() {
		Intent intent = new Intent(this, HomeActivity.class);
		intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
		startActivity(intent);
		finish();
	}

	@Override
	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if (keyCode == KeyEvent.KEYCODE_BACK) {
			return false;
		}
		return super.onKeyDown(keyCode, event);
	}
}
